package com.syq.controller;

import com.syq.annotation.RequiresPermissionsDesc;
import com.syq.pojo.DtsComment;
import com.syq.service.DtsCommentService;
import io.swagger.models.auth.In;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: AdminCommentController
 * @Description: TODO
 * @Create by: syq
 * @Date: 2022/7/28 8:16
 */

@CrossOrigin
@RestController
@RequestMapping("/admin/comment")
public class AdminCommentController {

    @Autowired
    private DtsCommentService dtsCommentService;

    @RequiresPermissionsDesc(menu = {"商品管理","评论"},button = "查询")
    @RequiresPermissions(value = "admin:comment:list")
    @GetMapping("/list")
    public Object list(@RequestParam(defaultValue = "1")Integer page,
                       @RequestParam(defaultValue = "10")Integer limit, Integer userId, Integer valueId,
                       @RequestParam(defaultValue = "add_time")String sort,
                       @RequestParam(defaultValue = "desc")String order){
        return dtsCommentService.findAll(page, limit, userId, valueId, sort, order);
    }

    @RequiresPermissionsDesc(menu = {"商品管理","评论"},button = "删除")
    @RequiresPermissions(value = "admin:comment:delete")
    @PostMapping("/delete")
    public Object delete(@RequestBody DtsComment dtsComment){
        return dtsCommentService.delete(dtsComment);
    }

}
